/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.openmrs.module.basicmodule.DSS.Interpreter.Function;

import org.openmrs.module.basicmodule.DSS.Interpreter.SymbolTable;
import org.openmrs.module.basicmodule.DSS.ast.IdTree;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openmrs.module.basicmodule.DSS.Interpreter.InterpreterVisitor;
import org.openmrs.module.basicmodule.DSS.ast.AST;

/**
 *
 * @author Stephen
 */
public class IsListFunction extends Function{
  
        private Class classForName(String classname) throws ClassNotFoundException
    {
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        Class theClass;
        if (loader != null)
             theClass = Class.forName(classname, false, loader);
           else
             theClass = Class.forName(classname);
        return theClass;
}
        
    @Override
    public Object execute(ArrayList args) {
        Object var = ((AST)args.get(0)).accept(new InterpreterVisitor());
        try {
            return (var.getClass() == classForName("java.util.ArrayList"));
                
    
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(IsBooleanFunction.class.getName()).log(Level.SEVERE, null, ex);
            
    }
        return false;
  }
}
